local caiyuan = fk.CreateSkill{
    name = "jin_heg__caiyuan",
    tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
    ["jin_heg__caiyuan"] = "才媛",
    [":jin_heg__caiyuan"] = "锁定技，回合开始时，若你的武将牌均明置且你本回合未明置过此武将牌，你摸两张牌；当你受到伤害后，若你的武将牌均明置，你暗置此武将牌。",

    ["$jin_heg__caiyuan1"] = "柳絮轻舞，撷芳赋诗。",
    ["$jin_heg__caiyuan2"] = "秀媛才德，知书达理。",
}

local H = require "packages.ol_hegemony.util"

caiyuan:addEffect(fk.Damaged,{
    can_trigger = function (self, event, target, player, data)
        if not player:hasSkill(caiyuan.name) or not H.allGeneralsRevealed(player) then return false end
        return target == player
      end,
      on_cost = Util.TrueFunc,
      on_use = function (self, event, target, player, data)
          H.hideBySkillName(player, caiyuan.name)
      end,
})

caiyuan:addEffect(fk.TurnStart,{
    can_trigger = function (self, event, target, player, data)
        if not player:hasSkill(caiyuan.name) or not H.allGeneralsRevealed(player) then return false end
        return player:getMark("jin_heg__caiyuan_shown-turn") == 0 and player == target
      end,
      on_cost = Util.TrueFunc,
      on_use = function (self, event, target, player, data)
          player:drawCards(2, caiyuan.name)
      end,
})

caiyuan:addEffect(fk.GeneralRevealed,{
    can_refresh = function (self, event, target, player, data)
        for _, v in pairs(data) do
          if v == "jin_heg__yanghuiyu" then
            return true
          end
        end
      end,
      on_refresh = function (self, event, target, player, data)
        player.room:setPlayerMark(player, "jin_heg__caiyuan_shown-turn", 1)
      end,
})

return caiyuan